package net.openl10n.api.project;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import net.openl10n.api.Namespaces;
import net.openl10n.api.document.DocumentRef;

@XmlType(name="projectType", namespace=Namespaces.PROJECT,propOrder={"name", "summary", "documents"})
@XmlRootElement(name="project", namespace=Namespaces.PROJECT)
public class Project {

	private String id;
	private String name;
	private String summary;
	private Integer version = 1;
	
	private List<DocumentRef> documents;
	
	public Project() {
	}
	
	public Project(String id, String name) {
		this.id = id;
		this.name = name;
	}
	
	public Project(String id, String name, Integer version) {
		this(id, name);
		this.version = version;
	}
	
	public Project(String id, String name, String summary) {
		this(id, name);
		this.summary = summary;
	}
	
	public Project(String id, String name, String summary, Integer version) {
		this(id, name, summary);
		this.version = version;
	}
	
	@XmlAttribute(name="id", required=true)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	@XmlElement(name="name", namespace=Namespaces.PROJECT, required=true)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@XmlElement(name="summary", namespace=Namespaces.PROJECT, required=false)
	public String getSummary() {
		return summary;
	}
	
	public void setSummary(String summary) {
		this.summary = summary;
	}

	@XmlAttribute(name="version", required=true)
	public Integer getVersion() {
		return version;
	}
	
	public void setVersion(Integer version) {
		this.version = version;
	}
	
	@XmlElementWrapper(name="documents", namespace=Namespaces.PROJECT, required=true)
	@XmlElement(name="document", namespace=Namespaces.DOCUMENT)
	public List<DocumentRef> getDocuments() {
		if(documents == null)
			documents = new ArrayList<DocumentRef>();
		return documents;
	}
}
